<template>
  <div id="integralActionTopSearch">
    <h1 class="con-right-title">
      互动积分策略
    </h1>
    <div class="search-box">
      <el-form
        ref="ruleForm"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <!-- 输入搜索部分 -->
        <el-form-item label="所属分类" prop="category">
          <el-select
            class="short-input"
            v-model="formInline.category"
            placeholder="请选择分类"
            clearable
          >
            <el-option
              v-for="item in nameList"
              :key="item.dictLabel"
              :label="item.dictLabel"
              :value="item.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务状态" prop="status">
          <el-select
            class="short-input"
            v-model="formInline.status"
            placeholder="请选择状态"
            clearable
          >
            <el-option
              v-for="item in statusList"
              :key="item.dictLabel"
              :label="item.dictLabel"
              :value="item.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务名称" prop="taskName">
          <el-input
            v-model="formInline.taskName"
            placeholder="请输入任务名称"
            size="small"
            class="numberInput"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item class="s-btn">
          <el-button
            type="success"
            icon="el-icon-search"
            @click="toSearch('ruleForm')"
          >
            查询
          </el-button>
          <el-button type="success" plain @click="reset">
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { sysNormalDisable } from '@utils/dictionariesFunc'
import { getDpNum } from '@/api/system/user'
export default {
  name: 'integralActionTopSearch',
  msg: '互动积分策略-顶部搜索',
  props: {
    formInline: {
      type: Object,
      default: function() {
        return {
          status: '', // 任务状态
          category: '', // 请选择分类
          taskName: '' // 任务名称
        }
      }
    }
  },
  data() {
    return {
      statusList: [{ dictLabel: '全部', dictValue: '' }],// 任务状态
      nameList: [{ dictLabel: '全部', dictValue: '' }]// 分类
    }
  },
  mounted() {
    this.getStatusList()
  },
  methods: {
    async getStatusList() {
      // 任务状态
      let data = await sysNormalDisable(
        'strategy_category_status',
        'strategy_category_status'
      )
      this.statusList = this.statusList.concat(data)
      // 分类
      let data2 = await sysNormalDisable(
        'strategy_category',
        'strategy_category'
      )
      this.nameList = this.nameList.concat(data2)
    },
    /* 搜索 */
    toSearch(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('toSearch')
        } else {
          return false
        }
      })
    },
    /* 重置 */
    reset() {
      this.$refs['ruleForm'].resetFields()
      this.setDefaultValue()
    }
  }
}
</script>

<style lang="less">
#integralActionTopSearch {
}
</style>
